package ToYesterday.Day03;


public class Solution2 {

    public static void main(String[] args) {

    }
    public static ListNode insertNode(ListNode head, int val) {
        // write your code here
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode newVal = new ListNode(val);
        ListNode nmp = dummy;
        while (nmp.next!=null&&nmp.next.val<val){
            nmp=nmp.next;
        }
        newVal.next = nmp.next;
        nmp.next=newVal;
        return dummy.next;

    }


    public ListNode findNode(ListNode head, int val) {
        // write your code here
        while (head!=null){
            if (val==head.val){
                return new ListNode(val);
            }
            head = head.next;
        }
        return null;
    }
}
